package com.ysc.task.controller;

import com.ysc.task.entity.User;
import com.ysc.task.entity.dto.UserLoginDTO;
import com.ysc.task.entity.dto.UserRegisterDTO;
import com.ysc.task.entity.dto.UserUpdateDTO;
import com.ysc.task.service.IUserService;
import com.ysc.task.util.R;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * Version: 1.0
 * Class Name: UserController
 * Description: 用户Controller
 * Author: ysc
 * Date: 2024/3/31 13:06
 */
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
@CrossOrigin
public class UserController {

    private final IUserService userService;

    @PostMapping("/register")
    public R register(@RequestBody UserRegisterDTO userRegisterDTO) {
        return userService.register(userRegisterDTO);
    }

    @PostMapping("/login")
    public R login(@RequestBody UserLoginDTO userLoginDTO) {
        return userService.login(userLoginDTO);
    }

    @PostMapping("/update")
    public R update(@RequestBody UserUpdateDTO userUpdateDTO) {
        return userService.update(userUpdateDTO);
    }
}
